package com.ruoyi.web.controller.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ISysUnitWordService;

/**
 * 但愿-单词信息
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/unit/word")
public class SysUnitWordController extends BaseController
{
    @Autowired
    private ISysUnitWordService sysUnitWordService;

    /**
     * 批量选择单词加入单元
     */
    @PreAuthorize("@ss.hasPermi('system:class:edit')")
    @Log(title = "单元-单词管理", businessType = BusinessType.GRANT)
    @PostMapping("/addBatch/{unitId}/{wordIds}")
    public AjaxResult addBatch(@PathVariable Long unitId, @PathVariable Long[] wordIds)
    {
        return toAjax(sysUnitWordService.batchInsertUnitWord(unitId, wordIds));
    }

    /**
     * 批量取消班级和学员关联
     */
    @PreAuthorize("@ss.hasPermi('system:class:edit')")
    @Log(title = "单元-单词管理", businessType = BusinessType.GRANT)
    @DeleteMapping("/cancelAll")
    public AjaxResult cancelAll(Long unitId)
    {
        return toAjax(sysUnitWordService.deleteUnitWordByUnitId(unitId));
    }
}